﻿<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" autoFlush="true"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="/WEB-INF/qa-category.tld" prefix="cat"%>
<%@ taglib uri="/WEB-INF/qautil.tld" prefix="qautil"%>
<%request.setAttribute("curDate",new java.util.Date());%>
<logic:present name="questioncategory">
	<html:link page="/tech.mrqa?action=list&categoryType=2">MFer 技术</html:link><cat:catlinks objType="C"/><br>
	<div align="left"><cat:insert type="T" categoryType="2"/></div>
<!--
    <c:if test="${param.catId == 16}">
        <span class="title1">
            网站调研
        </span>
    </c:if>
-->
    <c:if test="${questioncategory.onlyForAdmin == 'N' || questioncategory.onlyForAdmin == 'I'}">
    <div align="left" style="padding-top:5px;">
    <span class="title" id="list">
        <html:link page="/tech.mrqa?action=list&categoryType=2" paramId="catId" paramName="questioncategory" paramProperty="id" styleClass="tab">
            全部帖子
        </html:link>
    </span>
    <span class="title" id="hotlist">
        <html:link page="/tech.mrqa?action=hotlist&categoryType=2" paramId="catId" paramName="questioncategory" paramProperty="id" styleClass="tab">
            热点帖子
        </html:link>
    </span>
    <span class="title" id="complicatedlist">
        <html:link page="/tech.mrqa?action=complicatedlist&categoryType=2" paramId="catId" paramName="questioncategory" paramProperty="id"  styleClass="tab">
            加急帖子
        </html:link>
    </span>
    <span class="title" id="recommendedlist">
        <html:link page="/tech.mrqa?action=recommendedlist&categoryType=2" paramId="catId" paramName="questioncategory" paramProperty="id" styleClass="tab">
            推荐帖子
        </html:link>
    </span>
    </div>
    </c:if>
    <c:if test="${questioncategory.onlyForAdmin == 'N' || questioncategory.onlyForAdmin == 'I'}">
    <display:table name="questions" class="qlist" id="question" cellpadding="0" cellspacing="0">
        <display:column title="分类">
            <c:set var="qcatId" value="${question.mrIaskCategory.id}"/>
            <html:link page="/tech.mrqa?action=list&categoryType=2" paramId="catId" paramName="qcatId">
                [<c:out value="${question.mrIaskCategory.name}"/>]
            </html:link>
        </display:column>
        <display:column title="标题">
            <html:link page="/tech.mrqa?action=view" paramId="id" paramName="question" paramProperty="id">
            	<c:if test="${question.titleAttribute != null}">
            		<span style="<c:out value="${question.titleAttribute}" />">
            	</c:if>
                <c:out value="${question.title}" escapeXml="false"/> <c:if test="${question.isExpired == true}">(已过期)</c:if>
              <c:if test="${question.titleAttribute != null}">
            		</span>
            	</c:if>
            </html:link>
            <c:set var="differ" value="${(curDate.time-question.postDate.time)/3600000}"/>
            <c:if test="${differ <= 48}">
                <font color="#FF0000" title="48小时内新帖子">(new)</font>
            </c:if>
            <c:if test="${question.state == '2' or question.state == '5'}">
                <font color="#FF0000" title="加急帖子">(急)</font>
            </c:if>
            <c:if test="${question.isSecondaryTop == true}">
                <font color="#FF0000" title="被置顶">(置顶)</font>
            </c:if>
            <c:if test="${question.fileName != null and question.fileName != ''}">
                <img src="qa/images/icon/attachment.gif" alt="有附件"/>
            </c:if>
    <%
        request.setAttribute("answersSizeInViewQuestionPage",com.mr.qa.GlobalConfigs.NUMBER_ANSWER_FOR_VIEW_QUESTION);
    %>
                <c:set var="answerSize" value="${fn:length(question.mrIaskAnswers)}"/>
            <c:if test="${answerSize > answersSizeInViewQuestionPage}">                
                <c:set var="getFloatDivNumber" value="${answerSize / answersSizeInViewQuestionPage}"/>
                <fmt:formatNumber type="number" var="getRoundedDivNumber" value="${answerSize/answersSizeInViewQuestionPage}" maxFractionDigits="0"/>
                <c:set var="getModNumber" value="${answerSize % answersSizeInViewQuestionPage}"/>
                <fmt:formatNumber type="number" var="getRoundedDivNumber" value="${answerSize/answersSizeInViewQuestionPage}" maxFractionDigits="0"/>
                <c:set var="getDivNumber" value="${((getRoundedDivNumber-getFloatDivNumber)<=0.5 and (getRoundedDivNumber-getFloatDivNumber) > 0)?(getRoundedDivNumber-1):getRoundedDivNumber}"/>
                    <font color="black">[</font>
                    <fmt:formatNumber type="number" var="lastPageNo" value="${getModNumber==0?getDivNumber:(getDivNumber+1)}" maxFractionDigits="0"/>
                    <c:url var="lastPageLink" value="/tech.mrqa?action=view&gotoLastPage=true">
                        <c:param name="page" value="${lastPageNo}"/>
                        <c:param name="id" value="${question.id}"/>
                    </c:url><a href="<c:out value="${lastPageLink}"/>"><c:out value="${lastPageNo}"/></a>
                    <font color="black">]</font>
                </c:if>
        </display:column>
        <display:column title="作者" style="width:90;">
                    <c:set var="user_id" value="${question.mrIaskUser.id}"/>
                    <html:link page="/user.mrqa?action=viewuserbyother" styleId="author" paramId="id" paramName="user_id">
                       <c:out value="${question.mrIaskUser.loginName}"/>
                    </html:link><br>
                    <fmt:formatDate value="${question.postDate}" type="both" pattern="yyyy-MM-dd"/>
        </display:column>
        <display:column title="人气">
            <c:out value="${question.viewCount}"/>/<c:out value="${answerSize}"/>
        </display:column>
        <display:column title="最后更新" style="width:90;">
                <c:if test="${answerSize > 0}">
                    <c:forEach var="answer" items="${question.mrIaskAnswers}" begin="${answerSize-1}">
                        <c:if test="${answer.mrIaskUser != null and not answer.isAnonymous}">
                            <c:url value="/user.mrqa?action=viewuserbyother" var="userlik">
                                <c:param name="id" value="${answer.mrIaskUser.id}"/>
                            </c:url>
                            <a href="<c:out value="${userlik}"/>"><c:out value="${answer.mrIaskUser.loginName}"/></a>
                        </c:if>
                        <c:if test="${answer.mrIaskUser == null or answer.isAnonymous}">
                            <c:out value="${answer.anonymousUser}"/>
                        </c:if>
                    </c:forEach>
                </c:if>
                <c:if test="${answerSize == 0}">
                    <html:link page="/user.mrqa?action=viewuserbyother" styleId="author" paramId="id" paramName="user_id">
                        <c:out value="${question.mrIaskUser.loginName}"/>
                    </html:link>                    
                </c:if><br>
                <fmt:formatDate value="${question.changeDate}" type="both" pattern="yyyy-MM-dd HH:mm"/>
        </display:column>
    </display:table>
    </c:if>
    <c:if test="${questioncategory.onlyForAdmin == 'Y'}">
        <display:table name="questions" class="qlist" id="question" cellpadding="0" cellspacing="0">
            <display:column title="公告信息">
                <html:link page="/tech.mrqa?action=view" paramId="id" paramName="question" paramProperty="id">
                	<c:if test="${question.titleAttribute != null}">
            				<span style="<c:out value="${question.titleAttribute}" />">
            			</c:if>
                    <c:out value="${question.title}" escapeXml="false"/>
                  <c:if test="${question.titleAttribute != null}">
            			</span>
            			</c:if>
                </html:link>
            </display:column>
            <display:column title="访问">
                <c:out value="${question.viewCount}"/>
            </display:column>
            <display:column title="最后更新" format="{0,date,yyyy-MM-dd HH:mm:ss}" property="changeDate"/>
        </display:table>
    </c:if>
    <c:if test="${questioncategory.onlyForAdmin == 'T'}">
        <display:table name="questions" class="qlist" id="question" cellpadding="0" cellspacing="0">
            <display:column title="调研项目">
                <html:link page="/tech.mrqa?action=view" paramId="id" paramName="question" paramProperty="id">
                	<c:if test="${question.titleAttribute != null}">
            				<span style="<c:out value="${question.titleAttribute}" />">
            			</c:if>
                    <c:out value="${question.title}" escapeXml="false"/>
                  <c:if test="${question.titleAttribute != null}">
            				</span>
            			</c:if>
                </html:link>
            </display:column>
            <display:column title="访问">
                <c:out value="${question.viewCount}"/>
            </display:column>
            <display:column title="最后更新" format="{0,date,yyyy-MM-dd HH:mm:ss}" property="changeDate"/>
        </display:table>
    </c:if>
</logic:present>
<!-- no cat specified -->
<logic:notPresent name="questioncategory">
    <html:link page="/tech.mrqa?action=list&categoryType=2">MFer 技术</html:link><cat:catlinks objType="C"/><br>
    <div align="left"><cat:insert type="T" categoryType="2"/></div>
    <div align="left" style="padding-top:5px;">
    <span class="title" id="list">
        <html:link page="/tech.mrqa?action=list&categoryType=2" styleClass="tab">
            全部帖子
        </html:link>
    </span>
    <span class="title" id="hotlist">
        <html:link page="/tech.mrqa?action=hotlist&categoryType=2"  styleClass="tab">
            热点帖子
        </html:link>
    </span>
    <span class="title" id="complicatedlist">
        <html:link page="/tech.mrqa?action=complicatedlist&categoryType=2"  styleClass="tab">
            加急帖子
        </html:link>
    </span>
    <span class="title" id="recommendedlist">
        <html:link page="/tech.mrqa?action=recommendedlist&categoryType=2" styleClass="tab">
            推荐帖子
        </html:link>
    </span>
    </div>
    <table class="qlist" cellpadding="0" cellspacing="0" align="center">
    <thead>
        <tr>
        <th>分类</th>
        <th>标题</th>
        <th width="90">作者</th>
        <th>人气</th>
        <th width="90">最后更新</th>
        </tr>
    </thead>
    <tbody>
    <%
        request.setAttribute("answersSizeInViewQuestionPage",com.mr.qa.GlobalConfigs.NUMBER_ANSWER_FOR_VIEW_QUESTION);
    %>
    <c:set var="i" value="1"/>
    <c:forEach var="question" items="${questions}">
       <c:if test="${question.mrIaskCategory.state != '1'}">     
        <c:if test="${i%2 > 0}">
        <c:set var="tdclass" value="odd"/>
        </c:if>
        <c:if test="${i%2 == 0}">
        <c:set var="tdclass" value="even"/>
        </c:if>
        <c:set var="i" value="${i+1}"/>    
        <tr class="<c:out value="${tdclass}"/>">
            <td>
                <c:set var="qcatId" value="${question.mrIaskCategory.id}"/>
                <html:link page="/tech.mrqa?action=list&categoryType=2" paramId="catId" paramName="qcatId">
                    [<c:out value="${question.mrIaskCategory.name}"/>]
                </html:link>
            </td>
            <td>
                <html:link page="/tech.mrqa?action=view" paramId="id" paramName="question" paramProperty="id">
                	<c:if test="${question.titleAttribute != null}">
            				<span style="<c:out value="${question.titleAttribute}" />">
            			</c:if>
                    <c:out value="${question.title}" escapeXml="false"/> <c:if test="${question.isExpired == true}">(已过期)</c:if>
                  <c:if test="${question.titleAttribute != null}">
            				</span>
            			</c:if>
                </html:link>
                <c:set var="differ" value="${(curDate.time-question.postDate.time)/3600000}"/>
                <c:if test="${differ <= 48}">
                    <font color="#FF0000" title="48小时内新帖子">(new)</font>
                </c:if>
                <c:if test="${question.state == '2' or question.state == '5'}">
                    <font color="#FF0000" title="加急帖子">(急)</font>
                </c:if>
                <c:if test="${question.isTop == true}">
                    <font color="#FF0000" title="被置顶">(置顶)</font>
                </c:if>
                <c:if test="${question.fileName != null and question.fileName != ''}">
                    <img src="qa/images/icon/attachment.gif" alt="有附件"/>
                </c:if>
                <c:set var="answerSize" value="${fn:length(question.mrIaskAnswers)}"/>
            <c:if test="${answerSize > answersSizeInViewQuestionPage}">
                <c:set var="getFloatDivNumber" value="${answerSize / answersSizeInViewQuestionPage}"/>
                <c:set var="getModNumber" value="${answerSize % answersSizeInViewQuestionPage}"/>
                <fmt:formatNumber type="number" var="getRoundedDivNumber" value="${answerSize/answersSizeInViewQuestionPage}" maxFractionDigits="0"/>
                <c:set var="getDivNumber" value="${((getRoundedDivNumber-getFloatDivNumber)<=0.5 and (getRoundedDivNumber-getFloatDivNumber) > 0)?(getRoundedDivNumber-1):getRoundedDivNumber}"/>
                   <font color="black">[</font>
                    <fmt:formatNumber type="number" var="lastPageNo" value="${getModNumber==0?getDivNumber:(getDivNumber+1)}" maxFractionDigits="0"/>
                    <c:url var="lastPageLink" value="/tech.mrqa?action=view&gotoLastPage=true">
                        <c:param name="page" value="${lastPageNo}"/>
                        <c:param name="id" value="${question.id}"/>
                    </c:url><a href="<c:out value="${lastPageLink}"/>"><c:out value="${lastPageNo}"/></a>
                    <font color="black">]</font>
            </c:if>
            </td>
            <td>
                    <c:set var="user_id" value="${question.mrIaskUser.id}"/>
                    <html:link page="/user.mrqa?action=viewuserbyother" styleId="author" paramId="id" paramName="user_id">
                        <c:out value="${question.mrIaskUser.loginName}"/>
                    </html:link><br>
                    <fmt:formatDate value="${question.postDate}" type="both" pattern="yyyy-MM-dd"/>
            </td>
            <td>
                <span title="访问"><c:out value="${question.viewCount}"/></span>/<span title="回复"><c:out value="${answerSize}"/></span>
            </td>
            <td>
                <c:if test="${answerSize > 0}">
                    <c:forEach var="answer" items="${question.mrIaskAnswers}" begin="${answerSize-1}">
                        <c:if test="${answer.mrIaskUser != null and not answer.isAnonymous}">
                            <c:url value="/user.mrqa?action=viewuserbyother" var="userlik">
                                <c:param name="id" value="${answer.mrIaskUser.id}"/>
                            </c:url>
                            <a href="<c:out value="${userlik}"/>"><c:out value="${answer.mrIaskUser.loginName}"/></a>
                        </c:if>
                        <c:if test="${answer.mrIaskUser == null or answer.isAnonymous}">
                            <c:out value="${answer.anonymousUser}"/>
                        </c:if>
                    </c:forEach>
                </c:if>
                <c:if test="${answerSize == 0}">
                    <html:link page="/user.mrqa?action=viewuserbyother" styleId="author" paramId="id" paramName="user_id">
                        <c:out value="${question.mrIaskUser.loginName}"/>
                    </html:link>                    
                </c:if><br>
                <fmt:formatDate value="${question.changeDate}" type="both" pattern="yyyy-MM-dd HH:mm"/>
            </td>
        </tr>
      </c:if>  
    </c:forEach>
    </tbody>
    </table>
</logic:notPresent>
<qautil:page action="/tech.mrqa"/>
<script type="text/javascript">
    var selectedView = '<c:out value="${param.action}"/>';
    function initView()
    {
        try
        {
            if('' != selectedView)
            {
                var selectedViewSpan = document.getElementById(selectedView);
                if(selectedViewSpan == null)return;
                selectedViewSpan.className = "title1";
            }
        }
        catch(err)
        {
            alert(err.description);
        }
    }
    initView();
</script>
<c:if test="${questionsSize != null and questionsSize < questionsSizePerPage}">
<br>
<br>
<div align="center">
<script type="text/javascript"><!--
google_ad_client = "pub-3370373040606812";
/* MR_Iask_List 468x60, by William 08-8-30 */
google_ad_slot = "8374166115";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</c:if>